package jointpart.assignment3;

import static org.junit.Assert.*;

import java.io.IOException;


import org.junit.Test;

import shared.URLList;
import shared.WordList;

public class Searcher3Test {	
	//Test data sets:
	String dataSetA = "data/test/dataSetA.txt";
	WordList dataSetAList = null;
	
	String dataSetB = "data/test/dataSetB.txt";
	WordList dataSetBList = null;
	
	String dataSetC = "data/test/dataSetC.txt";
	URLList dataSetCLink1 = new URLList("1", null);
	WordList dataSetCList = new WordList("your", dataSetCLink1, null);
	
	String dataSetD = "data/test/dataSetD.txt";
	URLList dataSetDLink1 = new URLList("1", null);
	WordList dataSetDList = new WordList("us", dataSetCLink1, 
			new WordList("to", dataSetCLink1, 
					new WordList("belong", dataSetCLink1, 
							new WordList("are", dataSetCLink1, 
									new WordList("bases", dataSetCLink1, 
											new WordList("your", dataSetCLink1, null))))));

	String dataSetE = "data/test/dataSetE.txt";
	URLList dataSetELink1 = new URLList("1", null);
	WordList dataSetEList = new WordList("your", dataSetELink1, null);
	
	String dataSetF = "data/test/dataSetF.txt";
	URLList dataSetFLink1 = new URLList("1", null);
	URLList dataSetFLink2 = new URLList("2", new URLList("1", null));
	WordList dataSetFList = new WordList("us", dataSetFLink1, 
			new WordList("to", dataSetFLink1, 
					new WordList("belong", dataSetFLink1, 
							new WordList("are", dataSetFLink1, 
									new WordList("bases", dataSetFLink2, 
											new WordList("your", dataSetFLink2, null))))));


	/*Test of findURL*/
	@Test
	public void testFindURLA() {
		assertEquals(new URLList("2", new URLList("1", null)), Searcher3.findURL(dataSetFLink2, "2"));
	}
	@Test
	public void testFindURLB() {
		assertEquals(null, Searcher3.findURL(null, "2"));
	}
	@Test
	public void testFindURLC() {
		assertEquals(null, Searcher3.findURL(dataSetFLink2, null));
	}
	
	
	/*Test of findWord */
	@Test
	public void testFindWordA() {
		assertEquals(new WordList("are", dataSetFLink1, 
								new WordList("bases", dataSetFLink2, 
										new WordList("your", dataSetFLink2, null))), Searcher3.findWord(dataSetFList, "are"));
	}
	@Test
	public void testFindWordB() {
		assertEquals(null, Searcher3.findWord(null, "are"));
	}
	@Test
	public void testFindWordC() {
		assertEquals(null, Searcher3.findWord(dataSetFList, null));
	}

	/*Test of readWordList*/
	@Test
	public void testReadWordListA() throws IOException {
		assertEquals(dataSetAList, Searcher3.readWordList(dataSetA));
	}
	@Test
	public void testReadWordListB() throws IOException {
		assertEquals(dataSetBList, Searcher3.readWordList(dataSetB));
	}
	@Test
	public void testReadWordListC() throws IOException {
		assertEquals(dataSetCList, Searcher3.readWordList(dataSetC));
	}
	@Test
	public void testReadWordListD() throws IOException {
		assertEquals(dataSetDList, Searcher3.readWordList(dataSetD));
	}
	@Test
	public void testReadWordListE() throws IOException {
		assertEquals(dataSetEList, Searcher3.readWordList(dataSetE));
	}
	@Test
	public void testReadWordListF() throws IOException {
		assertEquals(dataSetFList, Searcher3.readWordList(dataSetF));
	}

}
